<% @title = t(".title") %>

<div class="t-body">
  <h2 class="page__subheading"><%= t ".mfa.multifactor_auth" %></h2>
  <% if @user.mfa_enabled? %>
    <div class="mfa__header-wrapper">
      <h2 class="mfa__header mfa__header--compact"><%= t(".mfa.level.title")%></h2>
    </div>
    <p><%= t(".mfa.level_html") %></p>

    <%= form_tag multifactor_auth_path, method: :put, id: "mfa-edit" do %>
      <%= select_tag :level, options_for_select(@mfa_options, @user.mfa_level), class: "form__input form__select" %>

      <%= submit_tag t(".mfa.update"), class: "form__submit" %>
    <% end %>
  <% end %>

  <div class="mfa__header-wrapper">
    <h2 class="mfa__header mfa__header--compact"><%= t(".webauthn_credentials") %></h2>
    <% if @user.webauthn_enabled? %>
      <span class="badge badge--success"><%= t(".mfa.enabled") %></span>
    <% else %>
      <span class="badge badge--warning"><%= t(".mfa.disabled") %></span>
    <% end %>
  </div>

  <p><%= t(".webauthn_credential_note")%></p>

  <% if @user.webauthn_credentials.none? %>
    <p><i><%= t(".no_webauthn_credentials") %></i></p>
  <% else %>
    <div class="l-mb-8">
      <%= render @user.webauthn_credentials %>
    </div>
  <% end %>

  <%= render "webauthn_credentials/form", webauthn_credential: @webauthn_credential %>

  <% if @user.totp_enabled? %>
    <div class="mfa__header-wrapper">
      <h2 class="mfa__header mfa__header--compact"><%= t(".mfa.otp") %></h2>
      <span class="badge badge--success"><%= t(".mfa.enabled") %></span>
    </div>
    <p><%= t(".mfa.enabled_note") %></p>
    <%= form_tag totp_path, method: :delete, id: "mfa-delete" do %>
      <div class="text_field">
        <%= label_tag :otp, t(".otp_code"), class: "form__label" %>
        <%= text_field_tag :otp, "", class: "form__input", autocomplete: :off %>
      </div>
      <%= submit_tag t(".mfa.disable"), class: "form__submit" %>
    <% end %>
  <% else %>
    <div class="mfa__header-wrapper">
      <h2 class="mfa__header mfa__header--compact"><%= t(".mfa.otp") %></h2>
      <span class="badge badge--warning"><%= t(".mfa.disabled") %></span>
    </div>
    <p>
      <%= t(".mfa.disabled_html") %>
      <%= button_to t(".mfa.go_settings"), new_totp_path, method: "get", class: "form__submit" %>
    </p>
  <% end %>
</div>

<div class="t-body">
  <h2><%= link_to t('.reset_password.title'), new_password_path %></h2>
</div>

<div class="t-body">
  <h2><%= link_to t('api_keys.index.api_keys'), profile_api_keys_path %></h2>
</div>

<div class="t-body">
  <h2><%= link_to t('oidc.pending_trusted_publishers.index.title'), profile_oidc_pending_trusted_publishers_path %></h2>
  <span><%= t("oidc.pending_trusted_publishers.index.description_html") %></span>
</div>

<% if @user.oidc_api_key_roles.any? %>
  <div class="t-body">
    <h2><%= link_to t('oidc.api_key_roles.index.api_key_roles'), profile_oidc_api_key_roles_path %></h2>
  </div>
<% end %>

<% if @user.ownerships.any? %>
  <div class="t-body">
    <h2><%= link_to t("notifiers.show.title"), notifier_path %></h2>
  </div>
<% end %>
